<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('')}">

                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="title" id="title" value="{$info.title}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="desc" class="col-sm-2 control-label">描述:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="desc" id="desc" value="{$info.desc}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="url" class="col-sm-2 control-label">链接地址:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="url" id="url" value="{$info.url}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="img" class="col-sm-2 control-label">广告图片(640x100):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="img"><br /> 
                        <div name="img" class="upviewer">
                            <ul>
                                <notempty name="info['img']">
                                    <li>
                                        <img src="{$info.img}"/><a d_path="{$info.img}">删除</a>
                                    </li>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                         <input type="hidden" name="id" value="{$info.id}">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
            </form>
        </div>
</div>
<script>
$(function(){   
     
    $("#btn").click(function(){
        // 省市区
        var $form = $("#post_form");
        var $data = {};
        var $form_data = $form.serializeArray();
        $.each($form_data, function(k, v){
            $data[v['name']] = v['value'];
        })
        
        $.post($form.attr('action'), $data, function(obj){
            alert(obj.m);
            if(obj.s){
                if(typeof(obj.url)!= "undefined" && obj.url){
                    location.href = obj.url;
                }
            }
        })
        return false;
    })
});
</script>
